import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import LoginView from '../views/LoginView.vue'
import mainView from '../views/MainView.vue'
import AccountInformation from '../views/AccountInformation.vue'
import AdvertisingManagement from '../views/AdvertisingManagement.vue'
import AnnouncementManagement from '../views/AnnouncementManagement.vue'
import BusinessOverview from '../views/BusinessOverview.vue'
import ClassificationGoods from '../views/ClassificationGoods.vue'
import CouponsView from '../views/CouponsView.vue'
import LevelMembership from '../views/LevelMembership.vue'
import ListCoaches from '../views/ListCoaches.vue'
import ListGoods from '../views/ListGoods.vue'
import ListMembers from '../views/ListMembers.vue'
import ListVenues from '../views/ListVenues.vue'
import ManagementEvaluation from '../views/ManagementEvaluation.vue'
import MemberManagement from '../views/MemberManagement.vue'
import MembershipCard from '../views/MembershipCard.vue'
import PrivateEducationManagement from '../views/PrivateEducationManagement.vue'
import RecordAppointment from '../views/RecordAppointment.vue'
import RoleManagement from '../views/RoleManagement.vue'
import ShoppingMallOrder from '../views/ShoppingMallOrder.vue'
import SystemConfiguration from '../views/SystemConfiguration.vue'
import teamManagement from '../views/teamManagement.vue'
//王宇
import toView from '../components/wangyu/detailView.vue'
import listMembersView from '../components/wangyu/listMembersView.vue'
import EditingMaterials from '../components/wangyu/EditingMaterials.vue'
import levelMemberEditor from '../components/wangyu/levelMemberEditor.vue'
import levelMembershipView from '../components/wangyu/levelMembershipView.vue'
import addLevel from '../components/wangyu/addLevel.vue'
import listcoachesOne from '../components/wangyu/listcoachesOne.vue'
import listcoachesTwo from '../components/wangyu/listcoachesTwo.vue'
import listcoachesThree from '../components/wangyu/listcoachesThree.vue'
import listcoachesFour from '../components/wangyu/listcoachesFour.vue'
import shipcardOneView from '../components/wangyu/shipcardOneView.vue'
import shipcardTwoView from '../components/wangyu/shipcardTwoView.vue'
import shipcardTwoBox from '../components/wangyu/shipcardTwoBox.vue'
import shipAdd from '../components/wangyu/shipAdd.vue'
import shipcardTwoOne from '../components/wangyu/shipcardTwoOne.vue'
import listcoachesDetail from '../components/wangyu/listcoachesDetail.vue'
//王宇
//杨健
import GoodsAdd from '../components/yangjian/GoodsAdd.vue'
import GoodsEdit from '../components/yangjian/GoodsEdit.vue'
import shopDealWith from '../components/yangjian/shopDealWith.vue'
//杨健
//蒋旗
import addMember from '../components/jq/addMember.vue'
import editMember from '../components/jq/editMember.vue'
import addAdvertising from '../components/jq/addAdvertising.vue'
import editAdvertising from '../components/jq/editAdvertising.vue'
import permission from '../components/jq/Permission.vue'
//蒋旗
//曹翔博
import AddLessons from '../components/cao/AddLessons.vue'
import AddTrainer from '../components/cao/AddTrainer.vue'
import AppointmentRecords from '../components/cao/AppointmentRecords.vue'
import CalendarView from '../components/cao/CalendarView.vue'
import CourseView from '../components/cao/CourseView.vue'
import ListView from '../components/cao/ListView.vue'
import ScheduleView from '../components/cao/ScheduleView.vue'
import TrainerSchedule from '../components/cao/TrainerSchedule.vue'
//曹翔博
// 李佳会
import addVenues from '../components/ljh/addVenues.vue'
import addCoupons from '../components/ljh/addCoupons.vue'
// 李佳会
import record from "../components/zch/record.vue";
import sign from "../components/zch/sign.vue";
import booking from "../components/zch/booking.vue";


const history = createWebHistory();
const routes: Array<RouteRecordRaw> = [
    {
        path: "/",
        redirect: "/login",
        meta: {
            title: "登录",
        },
    },

    {
        //登录
        path: "/login",
        // name: "login",
        component: LoginView,
        meta: {
            title: "登录",
        },
    },
    {
        //主页
        path: "/mainView",
        component: mainView,
        redirect: "BusinessOverview",
        name: "home",
        children: [
            {
                //默认
                path: "",
                component: BusinessOverview,

                meta: {
                    title: "主页",
                },
            },
            {
                //经营概况
                path: "BusinessOverview",
                component: BusinessOverview,
                meta: {
                    title: "经营概况",
                    isShow: true,
                },
            },
            {
                //账号资料
                path: "AccountInformation",
                component: AccountInformation,
                meta: {
                    title: "账号资料",
                },
            },
            {
                //预约记录
                path: "RecordAppointment",
                component: RecordAppointment,
                meta: {
                    title: "预约记录",
                },
                children: [
                    {
                        path: "",
                        component: record,
                        meta: {
                            title: "预约记录",
                        },
                    },

                    {
                        path: "/record",
                        component: record,
                        meta: {
                            title: "预约记录",
                        },
                    },
                    {
                        path: "/sign",
                        component: sign,
                        meta: {
                            title: "预约记录",
                        },
                    },
                    {
                        path: "/booking",
                        component: booking,
                        meta: {
                            title: "预约记录",
                        }
                    },

                ]
            },
            //杨健
            {
                //商品增加
                path: 'GoodsAdd',
                component: GoodsAdd,
                meta: {
                    title: '增加商品'
                }
            },
            {
                //商品编辑
                path: 'GoodsEdit',
                component: GoodsEdit,
                meta: {
                    title: '编辑商品'
                }
            },
            {
                //处理订单
                path: 'shopDealWith',
                component: shopDealWith,
                meta: {
                    title: '处理订单'
                }
            },
            //杨健结束

            {
                //公告管理
                path: 'AnnouncementManagement',
                component: AnnouncementManagement,
                meta: {
                    title: '公告管理'
                }
            },
            {
                //商品分类
                path: 'ClassificationGoods',
                component: ClassificationGoods,
                meta: {
                    title: '商品分类'
                }
            },
            {
                //会员等级
                path: 'LevelMembership',
                component: LevelMembership,
                meta: {
                    title: '会员等级'
                },
                children: [{
                    path: '',
                    component: levelMembershipView,
                    meta: {
                        title: '会员等级'
                    },

                },
                {
                    path: 'levelMembershipView',
                    component: levelMembershipView,
                    meta: {
                        title: '会员等级'
                    },

                },
                {
                    path: 'levelMemberEditor',
                    component: levelMemberEditor,
                },
                {
                    path: 'addLevel',
                    component: addLevel
                }
                ]
            },
            {
                //教练列表
                path: 'ListCoaches',
                component: ListCoaches,
                meta: {
                    title: '教练列表'
                },
                children: [
                    {
                        path: '',
                        component: listcoachesOne

                    },
                    {
                        path: 'listcoachesOne',
                        component: listcoachesOne

                    },
                    {
                        path: 'listcoachesTwo',
                        component: listcoachesTwo

                    },
                    {
                        path: 'listcoachesThree',
                        component: listcoachesThree

                    },
                    {
                        path: 'listcoachesFour',
                        component: listcoachesFour

                    },
                ]
            },
            {
                //商品列表
                path: 'ListGoods',
                component: ListGoods,
                meta: {
                    title: '商品列表'
                }
            },
            {
                //会员列表
                path: 'ListMembers',
                component: ListMembers,
                meta: {
                    title: '会员列表'
                },
                children: [
                    {
                        path: '',
                        component: listMembersView,
                        meta: {
                            title: '查看详情'
                        }
                    },
                    {
                        path: 'listMembersView',
                        component: listMembersView,
                        meta: {
                            title: '查看详情'
                        }
                    },
                    {
                        path: 'toView',
                        component: toView,
                        meta: {
                            title: '查看详情'
                        }

                    },
                    {
                        path: 'EditingMaterials',
                        component: EditingMaterials,
                        meta: {
                            title: '编辑资料'
                        }

                    },
                ]
            },
            // ljh
            {
                //优惠券
                path: 'CouponsView',
                component: CouponsView,
                meta: {
                    title: '优惠券'
                }
            },
            {
                //场馆列表
                path: 'ListVenues',
                component: ListVenues,
                meta: {
                    title: '场馆列表'
                },
            },
            {
                //增加场馆
                path: 'addVenue',
                name: "addVenue",
                component: addVenues,
                meta: {
                    title: '增加场馆'
                }
            },
            {
                //增加优惠券
                path: 'addCoupons',
                name: "addCoupons",
                component: addCoupons,
                meta: {
                    title: '增加场馆'
                }
            },
            {
                //评价管理
                path: 'ManagementEvaluation',
                component: ManagementEvaluation,
                meta: {
                    title: '评价管理'
                }
            },
            {
                //成员管理
                path: 'MemberManagement',
                component: MemberManagement,
                meta: {
                    title: '成员管理'
                }
            },
            {
                //新增成员
                path: 'addMember',
                component: addMember,
                meta: {
                    title: '新增成员'
                }
            },
            {
                //编辑成员
                path: 'editMember',
                component: editMember,
                meta: {
                    title: '编辑成员'
                }
            },
            {
                path: 'permission',
                component: permission,
                meta: {
                    title: '权限设置'
                }
            },
            {
                path: 'AdvertisingManagement',
                component: AdvertisingManagement,
                meta: {
                    title: '广告管理'
                }
            },
            {
                path: 'addAdvertising',
                component: addAdvertising,
                meta: {
                    title: '新增广告'
                }
            },
            {
                path: 'editAdvertising',
                component: editAdvertising,
                meta: {
                    title: '编辑广告'
                }
            },
            {
                //会员卡
                path: 'MembershipCard',
                component: MembershipCard,
                meta: {
                    title: '会员卡'
                },
                children: [
                    {
                        path: '',
                        component: shipcardOneView
                    },
                    {
                        path: 'shipcardOneView',
                        component: shipcardOneView
                    },
                    {
                        path: 'shipcardTwoBox',
                        component: shipcardTwoBox,
                        children: [{
                            path: '',
                            component: shipcardTwoView,

                        },
                        {
                            path: 'shipcardTwoView',
                            component: shipcardTwoView,

                        },
                        {
                            path: 'listcoachesDetail',
                            component: listcoachesDetail,
                        },
                        {
                            path: 'shipAdd',
                            component: shipAdd,

                        },
                        {
                            path: 'shipcardTwoOne',
                            component: shipcardTwoOne,

                        },
                        ]
                    },

                ]
            },
            {
                //私教管理
                path: 'PrivateEducationManagement',
                component: PrivateEducationManagement,
                meta: {
                    title: '私教管理'
                }
            },
            {
                //预约记录
                path: 'RecordAppointment',
                component: RecordAppointment,
                meta: {
                    title: '预约记录'
                }
            },
            {
                //角色管理
                path: 'RoleManagement',
                component: RoleManagement,
                meta: {
                    title: '角色管理'
                }
            },
            {
                //商城订单
                path: 'ShoppingMallOrder',
                component: ShoppingMallOrder,
                meta: {
                    title: '商城订单'
                }
            },
            {
                //系统配置
                path: 'SystemConfiguration',
                component: SystemConfiguration,
                meta: {
                    title: '系统配置'
                }
            },
            //曹翔博
            {
                //添加团课
                path: "AddLessons",
                component: AddLessons,
                meta: {
                    title: "添加团课",
                },
            },
            {
                //预约记录
                path: "AppointmentRecords",
                component: AppointmentRecords,
                meta: {
                    title: "添加团课",
                },
            },
            {
                //添加私教
                path: "AddTrainer",
                component: AddTrainer,
                meta: {
                    title: "添加私教",
                },
            },
            {
                //排期
                path: "TrainerSchedule",
                component: TrainerSchedule,
                meta: {
                    title: "排期",
                },
            },
            {
                //团队管理
                path: 'teamManagement',
                component: teamManagement,
                meta: {
                    title: '团队管理'
                },
                children: [
                    {
                        path: "",
                        component: CourseView,
                    },
                    {
                        path: "ScheduleView",
                        component: ScheduleView,
                        children: [
                            {
                                path: "",
                                component: CalendarView,
                            },
                            {
                                path: "CalendarView",
                                component: CalendarView,
                            },
                            {
                                path: "ListView",
                                component: ListView,
                            }
                        ]
                    },
                    {
                        path: "CourseView",
                        component: CourseView,
                    }
                ]
            },

        ]
    }
]


const router = createRouter({
    history,
    routes,
});
router.beforeEach((to, from, next) => {
    const token: string | null = localStorage.getItem('token')
    if (!token && to.path !== '/login') {
        next('login')
    } else
        next()
})
export default router;
